// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: fengyang

#include <memory>
#include <string>

#include "coin2/base/log.h"
#include "coin2/exchange/base/market/enums.h"
#include "coin2/exchange/base/feed/ws/fix_connection.h"
#include "coin2/exchange/lmax_digital/feed_v1/fix_connection.h"

using namespace coin::proto;

namespace coin2::exchange::base::feed {
namespace impl {

std::shared_ptr<FixConnection> FixConnection::NewFixConnection(
    executor::LiveAsyncExecutor* exec,
    const WsConnectionConfig& config) {
  const auto& mea = config.mea_config->mea;
  if (mea == MarketExchangeApi{Spot, ExchangeType::Lmaxdigital, "v1"}) {
    std::shared_ptr<lmax_digital::feed_v1::FixConnection> con =
        std::make_shared<lmax_digital::feed_v1::FixConnection>(exec, config);
    return std::static_pointer_cast<FixConnection>(con);
  } else {
    THROW() << "[FixConnection Factory] not implemented for " << mea.String();
  }

  return {};
}

}  // namespace impl
}  // namespace coin2::exchange::base::feed
